#include "operateitem.h"
#include "ui_operateitem.h"

OperateItem::OperateItem(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::OperateItem)
{
    ui->setupUi(this);

    //部件事件过滤的注册
    ui->pushButton->installEventFilter(this);
    ui->pushButton_2->installEventFilter(this);
    ui->pushButton_3->installEventFilter(this);

    QFont font;
    font.setFamily("Microsoft YaHei");//设置字体
    font.setLetterSpacing(QFont::PercentageSpacing,120);//120字间距，默认100
    ui->pushButton->setFont(font);
    ui->pushButton_2->setFont(font);
    ui->pushButton_3->setFont(font);
}

OperateItem::~OperateItem()
{
    delete ui;
}

void OperateItem::setText(QString str)
{
    ui->pushButton->setText(str);
}

QString OperateItem::text()
{
    return ui->pushButton->text();
}

//点击了禁用按钮
void OperateItem::on_pushButton_clicked()
{
    emit sendOperateItem("1");
}

//点击了重置密码按钮
void OperateItem::on_pushButton_2_clicked()
{
    emit sendOperateItem("2");
}

//点击了修改信息按钮
void OperateItem::on_pushButton_3_clicked()
{
    emit sendOperateItem("3");
}

bool OperateItem::eventFilter(QObject *watched, QEvent *event)
{
    if(ui->pushButton==watched)
    {
        if(QEvent::Enter==event->type())
        {
            setCursor(Qt::PointingHandCursor); //设置鼠标样式
        }
        else if(QEvent::Leave==event->type())
        {
            setCursor(Qt::ArrowCursor); //设置鼠标默认样式
        }
    }
    if(ui->pushButton_2==watched)
    {
        if(QEvent::Enter==event->type())
        {
            setCursor(Qt::PointingHandCursor); //设置鼠标样式
        }
        else if(QEvent::Leave==event->type())
        {
            setCursor(Qt::ArrowCursor); //设置鼠标默认样式
        }
    }
    if(ui->pushButton_3==watched)
    {
        if(QEvent::Enter==event->type())
        {
            setCursor(Qt::PointingHandCursor); //设置鼠标样式
        }
        else if(QEvent::Leave==event->type())
        {
            setCursor(Qt::ArrowCursor); //设置鼠标默认样式
        }
    }

    return QObject::eventFilter(watched,event);
}
